<form role="form" name="form" class="form-horizontal" novalidate>
    <div class="modal-header">
        <h3 class="modal-title">{{model.title}}</h3>
    </div>
    <div class="modal-body">
        <fieldset>
            <legend>销售人员信息</legend>
            <div class="row">
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">姓名</span>
                        <input type="text" class="form-control" ng-model="model.salesman_name" ng-disabled="model.action == 'modify'" required ng-maxlength="6"/>
                    </div>
                </div>
                <div class="col-sm-3">
                    <div class="input-group">
                        <span class="input-group-addon">性别</span>
                        <select class="form-control" ng-model="model.salesman_sex">
                            <option value="男" selected>男</option>
                            <option value="女">女</option>
                        </select>
                    </div>
                </div>
                <div class="col-sm-5">
                    <div class="input-group">
                        <span class="input-group-addon">手机号</span>
                        <input type="text" class="form-control" ng-model="model.salesman_phone" ng-regexp="phone_num" required ng-maxlength="15"/>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-4">
                    <div class="input-group">
                        <span class="input-group-addon">渠道</span>
                        <select class="form-control" ng-model="model.channel">
                            <option value="团险">团险</option>
                            <option value="银保">银保</option>
                            <option value="个险">个险</option>
                        </select>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="input-group" ng-controller="datepicker_ctrl">
                        <span class="input-group-addon">申请时间</span>
                        <input type="text" class="form-control" ng-model="model.salesman_hiredate" readonly
                               datepicker-popup="{{format}}" min-date="minDate" max-date="maxDate" datepicker-options="dateOptions"
                               date-disabled="disabled(date, mode)" ng-click="open($event)" is-open="write_time_opened"
                               current-text="今天" close-text="关闭" clear-text="清除">
                    </div>
                </div>
                <div class="col-sm-5">
                    <div class="input-group">
                        <span class="input-group-addon">证件类别</span>
                        <select class="form-control" ng-model="model.salesman_card_type">
                            <option value="身份证">身份证</option>
                            <option value="驾驶证">驾驶证</option>
                        </select>
                    </div>
                </div>
                <div class="col-sm-7">
                    <div class="input-group">
                        <span class="input-group-addon">证件号</span>
                        <input type="text" class="form-control" ng-model="model.salesman_card_id" ng-regexp="idcard" required ng-maxlength="20"/>
                    </div>
                </div>
            </div>
        </fieldset>
        <fieldset style="margin-top: 10px">
            <legend>付款银行信息</legend>
            <div class="row">
                <div class="col-sm-5">
                    <div class="input-group">
                        <span class="input-group-addon">账户名</span>
                        <span class="input-group-addon" ng-if="model.action == 'modify' && (model.review_state != -6 || model.review_state == -6 && model.process_result.indexOf('户名') < 0)">{{model.salesman_bank_account_name}}</span>
                        <input type="text" class="form-control" ng-if="model.action == 'add' || model.action == 'modify' && model.review_state == -6 && model.process_result.indexOf('户名') >= 0" ng-model="model.salesman_bank_account_name" required ng-maxlength="25"/>
                    </div>
                </div>
                <div class="col-sm-7">
                    <div class="input-group">
                        <span class="input-group-addon">开户行</span>
                        <input type="text" class="form-control" ng-model="model.salesman_bank_name" required ng-maxlength="25"/>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-10">
                    <div class="input-group">
                        <span class="input-group-addon">账号</span>
                        <input type="text" class="form-control" ng-model="model.salesman_bank_account_number" ng-regexp="bank_acc_num" required ng-maxlength="25"/>
                    </div>
                </div>
            </div>
        </fieldset>
        <fieldset style="margin-top: 10px">
            <legend>保证金</legend>
            <div class="row">
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon">缴款金额</span>
                        <span class="input-group-addon" ng-if="model.action == 'modify'">￥{{model.salesman_cash_deposit}}</span>
                        <input type="number" class="form-control" ng-if="model.action == 'add'" ng-model="model.salesman_cash_deposit" 
                               ng-blur="generation_gives.compute_salesman_refunds()" required/>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="input-group">
                        <span class="input-group-addon">退款金额</span>
                        <span class="input-group-addon">￥{{model.salesman_refunds}}</span>
                    </div>
                </div>
            </div>
        </fieldset>
        <fieldset style="margin-top: 10px">
            <legend></legend>
            <div class="row" style="margin-bottom: 10px;">
                <div class="col-sm-3 text-center">
                    <button type="button" class="btn btn-sm btn-primary" ng-click="generation_gives.record()">
                        录入扣款明细
                    </button>
                </div>
                <div class="col-sm-3 text-center">
                    <button type="button" class="btn btn-sm btn-primary" ng-click="generation_gives.delete()">
                        删除扣款明细
                    </button>
                </div>
                <div class="col-sm-3 text-center">
                    <button type="button" class="btn btn-sm btn-primary" ng-click="generation_gives.print()">
                        打印退款声明
                    </button>
                </div>
                <div class="col-sm-3 text-center">
                    <button type="button" class="btn btn-sm btn-primary" ng-click="generation_gives.submit()">
                        提交退款申请
                    </button>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6 text-center">
                    <div class="input-group">
                        <span class="input-group-addon">扣款项目</span>
                        <input type="text" class="form-control" ng-model="model.deducted.item"/>
                    </div>
                </div>
                <div class="col-sm-6 text-center" style="margin-bottom: 8px;">
                    <div class="input-group">
                        <span class="input-group-addon">扣款金额￥</span>
                        <input type="text" class="form-control" ng-model="model.deducted.amount"/>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="input-group">
                        <span class="input-group-addon">备注</span>
                        <input type="text" class="form-control" ng-model="model.deducted.remark"/>
                    </div>
                </div>
                <div class="col-sm-12">
                    <table class="table" style="margin: 0;">
                        <thead>
                        <tr>
                            <th style="width: 32px;"></th>
                            <th >扣款项目</th>
                            <th style="width: 83px;">扣款金额</th>
                            <th>备注</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="_this in model.deducted_items">
                            <td>
                                <input type="checkbox" name="checkbox" style="width: 15px; height: 15px;" ng-model="_this.checked"/>
                            </td>
                            <td>{{_this.item}}</td>
                            <td>￥{{_this.amount}}</td>
                            <td>{{_this.remark}}</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </fieldset>
    </div>
    <div class="modal-footer">
        <button type="submit" class="btn btn-primary" ng-click="generation_gives.save(form.$valid)">保存</button>
        <button class="btn btn-warning" ng-click="cancel()">取消</button>
    </div>
</form>